<template>
  <div>
    <el-dialog
      v-loading.lock="loading"
      class="base-dialog system-user-dialog"
      :custom-class="'panna-dialog_big'"
      :append-to-body="true"
      :title="dataList.InspecTaskDetail"
      align="center"
      :close-on-click-modal="false"
      :visible.sync="dialogFormVisible"
      @closed="closeDialog"
    >
      <DeviceVerificationTaskView :id.sync="id"></DeviceVerificationTaskView>

      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="print('formData')">{{
          btn.Print
        }}</el-button>
        <el-button @click="cancel">{{ btn.Cancel }}</el-button>
      </div>
    </el-dialog>
    <DeviceVerificationTaskExportView
      v-if="dialogFormExportViewVisible"
      :id.sync="id"
      ref="DeviceVerificationTaskExportView"
      :print-state.sync="printState"
      :dialog-form-visible.sync="dialogFormExportViewVisible"
    />
  </div>
</template>

<script>
import { getList } from "../../../api/DeviceVerificationTask.js";
import { mapGetters } from "vuex";
import DeviceVerificationTaskExportView from "./DeviceVerificationTaskExportView.vue";
import DeviceVerificationTaskView from "./DeviceVerificationTaskView.vue";
export default {
  name: "DeviceVerificationTaskViewDialog",
  components: { DeviceVerificationTaskView, DeviceVerificationTaskExportView },
  props: {
    dialogFormVisible: {
      type: Boolean,
      default: false,
    },
    id: {
      type: String,
      default: "0",
    },
  },

  data() {
    return {
      list: [],
      printState: false,
      size: "12px",
      listDeviceVerification: [],
      dialogFormExportViewVisible: false,
      loading: false,
      innerDialogFormVisible: false,
      formLabelWidth: "120px",
      formData: {
        verificationPersonName: "",
        sysBusinessImgWarehouseList: [],
        sysBusinessFileWarehouseList: [],
        conclusion: "",
        conclusionReason: "",
        deviceStatusName: "",
        verificationDateNext: "",
      },
    };
  },
  computed: {
    ...mapGetters(["fileDomain", "fileBucket"]),
    btn() {
      return this.$t("ModuleDevice.buttons");
    },
    dataList() {
      return this.$t("ModuleDevice.Device");
    },
  },
  watch: {},
  created() {
    this.initData();
  },
  methods: {
    // 打印
    initData() {
      this.loading = true;
      getList({ id: this.id })
        .then((res) => {
          if (res.data.dataList != null && res.data.dataList.length > 0) {
            this.formData = res.data.dataList[0];
          }

          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
    print() {
      this.printState = true;
      this.dialogFormExportViewVisible = true;
    },
    getUrl(url) {
      // var res = `${this.$baseProtocol}//${this.fileDomain}/${this.fileBucket}/${url}`;
      var res = `${url}`;
      return res;
    },
    cancel() {
      this.$emit("update:dialogFormVisible", false);
    },
    closeDialog() {
      this.cancel();
    },
  },
};
</script>
